home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / iflib / getheader.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-04  |  2.7 KB  |  108 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "lutil.h"
  4. #include "ftn.h"
  5. #include "bread.h"
  6. #include "config.h"
  7.  
  8. faddr pktfrom;
  9. char pktpwd[9];
  10.  
  11. int getheader(f,t,pkt)
  12. faddr *f,*t;
  13. FILE *pkt;
  14. {
  15.     int i,pwdok;
  16.     int capword,capvalid;
  17.     int tome,pointcheck;
  18.     fa_list *al;
  19.  
  20.     f->domain=NULL;
  21.     f->name=NULL;
  22.     t->domain=NULL;
  23.     t->name=NULL;
  24.  
  25.     debug(5,"from node: %u",f->node=iread(pkt));
  26.     debug(5,"to   node: %u",t->node=iread(pkt));
  27.     debug(5,"year     : %u",iread(pkt));
  28.     debug(5,"month    : %u",iread(pkt));
  29.     debug(5,"day      : %u",iread(pkt));
  30.     debug(5,"hour     : %u",iread(pkt));
  31.     debug(5,"min      : %u",iread(pkt));
  32.     debug(5,"sec      : %u",iread(pkt));
  33.     debug(5,"rate     : %u",iread(pkt));
  34.     debug(5,"ver      : %u",iread(pkt));
  35.     debug(5,"from net : %u",f->net=iread(pkt));
  36.     debug(5,"to   net : %u",t->net=iread(pkt));
  37.     debug(5,"prodx    : 0x%04x",iread(pkt));
  38.     for (i=0;i<8;i++) pktpwd[i]=getc(pkt);
  39.     pktpwd[8]='\0';
  40.     debug(5,"password : %s",pktpwd);
  41.     if (pktpwd[0]) f->name=pktpwd;
  42.     debug(5,"from zone: %u",f->zone=iread(pkt));
  43.     debug(5,"to   zone: %u",t->zone=iread(pkt));
  44.     debug(5,"filler   : 0x%04x",iread(pkt));
  45.     debug(5,"capvalid : 0x%04x",capvalid=iread(pkt));
  46.     debug(5,"prodcode : 0x%04x",iread(pkt));
  47.     debug(5,"capword  : 0x%04x",capword=iread(pkt));
  48.     debug(5,"from zone: %u",iread(pkt));
  49.     debug(5,"to   zone: %u",iread(pkt));
  50.     debug(5,"from pnt : %u",f->point=iread(pkt));
  51.     debug(5,"to   pnt : %u",t->point=iread(pkt));
  52.     debug(5,"proddata : 0x%08lx",lread(pkt));
  53.  
  54.     if (feof(pkt) || ferror(pkt)) 
  55.     {
  56.         logerr("$Could not read packet header");
  57.         return 2;
  58.     }
  59.  
  60.     pointcheck=0;
  61.     if (((capword >> 8) == (capvalid & 0xff)) &&
  62.         ((capvalid >> 8) == (capword & 0xff)))
  63.         pointcheck=(capword & 0x0001);
  64.     else capword=0;
  65.  
  66.     debug(5,"capword=%04x, pointcheck=%s",capword,pointcheck?"yes":"no");
  67.  
  68.     pktfrom.name=NULL;
  69.     pktfrom.domain=NULL;
  70.     pktfrom.zone=f->zone;
  71.     pktfrom.net=f->net;
  72.     pktfrom.node=f->node;
  73.     if (pointcheck) pktfrom.point=f->point;
  74.     else pktfrom.point=0;
  75.  
  76.     tome=0;
  77.     for (al=whoami;al;al=al->next)
  78.     {
  79.     if (((t->zone == 0) || (t->zone == al->addr->zone)) &&
  80.         (t->net == al->addr->net) &&
  81.         (t->node == al->addr->node) &&
  82.         ((!pointcheck) || (t->point == al->addr->point)))
  83.         tome=1;
  84.     }
  85.  
  86.     pwdok=1;
  87.     for (al=pwlist;al;al=al->next)
  88.     {
  89.     if (((f->zone == 0) || (f->zone == al->addr->zone)) &&
  90.         (f->net == al->addr->net) &&
  91.         (f->node == al->addr->node) &&
  92.         ((!pointcheck) || (f->point == al->addr->point)))
  93.         if (strcasecmp(al->addr->name,pktpwd) != 0)
  94.         {
  95.             pwdok=0;
  96.             loginf("password got \"%s\", expected \"%s\"",
  97.                 pktpwd,al->addr->name);
  98.         }
  99.     }
  100.  
  101.     loginf("packet from node %s",ascfnode(f,0x1f));
  102.     loginf("         to node %s",ascfnode(t,0x1f));
  103.  
  104.     if (!tome) return 3;
  105.     else if (!pwdok) return 4;
  106.     else return 0;
  107. }
  108.